package com.woniu.p2p.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.p2p.entity.Homepage;
import com.woniu.p2p.entity.Invest;
import com.woniu.p2p.entity.New;
import com.woniu.p2p.entity.Show;
import com.woniu.p2p.service.P2PIndexService;
import com.woniu.p2p.vo.MonthAndWeekUserInvestVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

@RestController
@RequestMapping("/index")
public class P2PIndexController {

    @Autowired
    P2PIndexService p2PIndexService;

    @RequestMapping("/gethomepage")
    public Homepage findHomePageById(){
        Integer id=1;
        Homepage all = p2PIndexService.findAllHomepage(id);
        return all;
    }

    @RequestMapping("/getshow")
    public PageInfo<Show> findAllShow(){
        Integer start=1;
        Integer num=4;
        PageInfo<Show> allShow = p2PIndexService.findAllShow(start,num);
        return allShow;
    }

    @RequestMapping("/getinvest")
    public PageInfo<Invest> getinvest(){
        Integer start=1;
        Integer num=3;
        PageInfo<Invest> pageInfo = p2PIndexService.findAllInvestNewThree(start, num);
        return pageInfo;
    }

    @RequestMapping("/getinvestxin")
    public PageInfo<Invest> getinvestxin(){
        Integer start=1;
        Integer num=4;
        PageInfo<Invest> pageInfo = p2PIndexService.findAllInvestXin(start, num);
        return pageInfo;
    }

    @RequestMapping("/getnewTrend")
    public PageInfo<New> getnewTrend(){
        Integer start=1;
        Integer num=6;
        PageInfo<New> pageInfo = p2PIndexService.findAllNew(start, num);
        return pageInfo;
    }

    @RequestMapping("/getmonth")
    public PageInfo<MonthAndWeekUserInvestVo> getmonth() throws ParseException {
        Integer start=1;
        Integer num=6;
        PageInfo<MonthAndWeekUserInvestVo> pageInfo = p2PIndexService.findAllUserInvestByMonth(start, num);
        return pageInfo;
    }

    @RequestMapping("/getweek")
    public PageInfo<MonthAndWeekUserInvestVo> getweek() throws ParseException {
        Integer start=1;
        Integer num=6;
        PageInfo<MonthAndWeekUserInvestVo> pageInfo = p2PIndexService.findAllUserInvestByWeek(start, num);
        return pageInfo;
    }

    @RequestMapping("/getzong")
    public PageInfo<MonthAndWeekUserInvestVo> getzong(){
        Integer start=1;
        Integer num=6;
        PageInfo<MonthAndWeekUserInvestVo> pageInfo = p2PIndexService.findAllUserInvest(start, num);
        return pageInfo;
    }

}
